package com.framework.Controller;

import com.framerock.baselib.AA;
import com.framerock.baselib.CDate;
import com.framerock.server.TaskServer;
import com.framework.ACore.Controller;

/**
 * 计划任务处理
 * */
public class ControllerTask  extends Controller {


    @Override
    protected String runAction(String action) {
        if(action.equals("stop"))return stop();
        if(action.equals("restart"))return restart();
        return super.runAction(action);
    }

    @Override
    public String index() {
        return "Hi,"+ AA.APPTYPE+"/"+AA.VERSION+" task runing, now:"+ CDate.now()+"";
    }

    /**
     * 停止计划任务
     * */
    private String stop(){
        TaskServer.stop();
        return "Hi,"+ AA.APPTYPE+"/"+AA.VERSION+" task stop success, now:"+ CDate.now()+"";
    }

    /**
     * 开启计划任务
     * */
    private String restart(){
        TaskServer.restart();
        return "Hi,"+ AA.APPTYPE+"/"+AA.VERSION+" task start success, now:"+ CDate.now()+"";
    }
}
